import base64
from typing import List

import shortuuid
from peewee import JOIN

from afast_core.core_libs.captcha.cilent import generate_captcha
from afast_core.core_tools.jwt_helper import SimpleAuth
from infirmary_admin_src.infirmary_common.infirmary_controller import IAsyncSessionBaseController, IBaseController
from infirmary_admin_src.infirmary_common.infirmary_controller.rest_controller_with_depends import \
    RestControllerWithDepends
from fastapi import Request, Depends
from afast_core.core_tools import json_helper
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.schemas import SchemaBase


class XParam(SchemaBase):
    '''
    账号密码登录参数
    '''


class IController(IBaseController):
    '''
    定制相关约束检测函数逻辑步序
    '''

    def __init__(self, *, request: Request,
                 ):
        super().__init__(request=request)
        # 入参参数


@RestControllerWithDepends()
class AuthUserInfoIController(IController):

    def business_login(self):
        pass
        # 生成验证码
        random_str, image_data = generate_captcha(width=80, height=25)
        base64_data = str(base64.b64encode(image_data), "utf-8")  # 使用base64进行加密
        # request.session["session_code"] = random_str.lower()
        return {
            "id": "1",
            "username": "admin",
            "nickname": "超级管理员",
            "gender": 1,
            "email": "charles7c@126.com",
            "phone": "188****8888",
            "avatar": None,
            "description": "系统初始用户",
            "pwdResetTime": "2023-04-13 22:37:08",
            "registrationDate": "2023-04-13",
            "deptId": "1",
            "deptName": "Xxx科技有限公司",
            "permissions": ["*"],
            "roles": ["admin"]
        }
